#include "../include/mysqlConnection.h"
#include <cppconn/prepared_statement.h>

mysqlConnection::mysqlConnection(sql::Connection *con)
{
    this->_con=con;
    this->current_schema=_con->getSchema();
}

void mysqlConnection::change_scema(std::string new_schema)
{
    _con->setSchema(new_schema);
    this->current_schema=new_schema;
}

void mysqlConnection::keep_alive()
{
    sql::PreparedStatement *stm=_con->prepareStatement("select 1");
    sql::ResultSet *res =stm->executeQuery();
   
    while(res->next()){
        //消费掉数据
    }
    delete res;
    delete stm;
    std::cout<<"成功发送一个心跳"<<std::endl;
}

mysqlConnection::~mysqlConnection()
{
    std::cout<<"成功清理一个sql::Connection*"<<std::endl;
    delete _con;
}